<UserControl x:Class="OpenRm.Server.Gui.Modules.Monitor.Views.AgentsListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:Converters="clr-namespace:OpenRm.Server.Gui.Modules.Monitor.Converters" mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <SolidColorBrush x:Key="SelectedBackgroundBrush" Color="#DDD" />
        <SolidColorBrush x:Key="DisabledForegroundBrush" Color="#888" />
        <Style x:Key="{x:Type ListBoxItem}" TargetType="ListBoxItem">
            <Setter Property="SnapsToDevicePixels" Value="true"/>
            <Setter Property="OverridesDefaultStyle" Value="true"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBoxItem}">
                        <Border Name="Border" Padding="3" SnapsToDevicePixels="true">
                            <ContentPresenter/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter TargetName="Border" Property="Background"
                                        Value="{StaticResource SelectedBackgroundBrush}"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground"
                                        Value="{StaticResource DisabledForegroundBrush}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <DataTemplate x:Key="AgentListBoxItemTemplate">
            <StackPanel Orientation="Horizontal">
                <Ellipse Width="10" Height="10" 
                         Fill="{Binding Status, Converter={x:Static Converters:StaticConverters.StatusToBrushConverter}}" Stroke="Black" StrokeThickness="1"
                         Margin="2,0,2,0"
                         />
                <TextBlock Text="{Binding Name}"/>
                <!--<Image Source="Images\wol_64x64.png"/>-->
            </StackPanel>
        </DataTemplate>
    </UserControl.Resources>
    <Grid>
        <!-- http://zamjad.wordpress.com/2010/02/06/datatemplate-vs-controltemplate/ -->
            <ListBox 
                     ItemTemplate="{StaticResource AgentListBoxItemTemplate}"
                     ItemsSource="{Binding AgentsCollection}"
                     SelectedItem="{Binding CurrentEntity}"
                     />
    </Grid>
</UserControl>
